*This is the data analysis part of the program.
*This is used when the variables must be calculated, some more data entered, and then analyzed.
;

PROC IMPORT OUT= WORK.one DATAFILE= "C:\Users\tebert\OneDrive - University of Florida\Work\Manuscipts\Gender size\Final Pieces MS\Final Data.xlsx" 
 DBMS=xlsx REPLACE;
 SHEET="Transformed Variables"; 
 GETNAMES=YES;
RUN;
data one; set one;
if sex="F" or sex="f" then sex="female";
if sex="M" or sex="m" then sex="male";
if color1="B" or color1="b" then color1="blue";
if color1="G" or color1="g" then color1="green";
run;
data one; set one;
  if insectno ne "c04" then output;
run;

/*
data one; set one;
proc sort; by sex;
proc means; by sex;
proc sort; by color1;
proc means; by color1;
proc sort; by sex color1;
proc means; by sex color1;
run;
/*
proc glm plots=diagnostics;
model head=head|femur;
lsmeans sex;
lsmeans color1;
run;


model femur=head|femur;
lsmeans sex;
lsmeans color1;
run;
*/;
data two; set one;
femur=log(femur);
head=log(head);
proc sort; by sex color1;
run;

ods graphics on;
proc glm data=two plots=diagnostics; class sex color1; model NumPrbs=sex|color1|head|femur;   title 'NumPrbs';
proc glm data=two plots=diagnostics; class sex color1; model MnPrbs=sex|color1|head|femur;   title 'MnPrbs';
proc glm data=two plots=diagnostics; class sex color1; model sdPrbs=sex|color1|head|femur;   title 'sdPrbs';
proc glm data=two plots=diagnostics; class sex color1; model MdnPrbs=sex|color1|head|femur;   title 'MdnPrbs';
proc glm data=two plots=diagnostics; class sex color1; model DurFrstPrb=sex|color1|head|femur;   title 'DurFrstPrb';
proc glm data=two plots=diagnostics; class sex color1; model DurScndPrb=sex|color1|head|femur;   title 'DurScndPrb';
proc glm data=two plots=diagnostics; class sex color1; model TtlPrbTm=sex|color1|head|femur;   title 'TtlPrbTm';*duration of recording less duration of NP or Z;

*******************************************************************;
******** Variables for NP *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NumNP=sex|color1|head|femur;  title 'NumNP';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurNP=sex|color1|head|femur;  title 'TtlDurNP';
proc glm data=two plots=diagnostics; class sex color1; model MnDurNP=sex|color1|head|femur;  title 'MnDurNP';
proc glm data=two plots=diagnostics; class sex color1; model sdNP=sex|color1|head|femur;  title 'sdNP';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstPrbFrmStrt=sex|color1|head|femur;  title 'TmFrstPrbFrmStrt'; *Duration of first NP;
proc glm data=two plots=diagnostics; class sex color1; model DurScndZ=sex|color1|head|femur;  title 'DurScndZ'; *Duration of second NP;
proc glm data=two plots=diagnostics; class sex color1; model DurNnprbBfrFrstE1=sex|color1|head|femur;  title 'DurNnprbBfrFrstE1';
proc glm data=two plots=diagnostics; class sex color1; model DurNpFllwFrstSusE2=sex|color1|head|femur;  title 'DurNpFllwFrstSusE2';

*******************************************************************;
******** Variables for C or Pathway (=C+A+B) *************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NmbrC=sex|color1|head|femur;  title 'NmbrC';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurC=sex|color1|head|femur;  title 'TtlDurC';
proc glm data=two plots=diagnostics; class sex color1; model MnDurC=sex|color1|head|femur;  title 'MnDurC';
proc glm data=two plots=diagnostics; class sex color1; model sdC=sex|color1|head|femur;  title 'sdC';
proc glm data=two plots=diagnostics; class sex color1; model NmbrShrtC=sex|color1|head|femur;  title 'NmbrShrtC';
proc glm data=two plots=diagnostics; class sex color1; model ShrtCbfrE1=sex|color1|head|femur;  title 'ShrtCbfrE1';
proc glm data=two plots=diagnostics; class sex color1; model PrcntPrbC=sex|color1|head|femur; title 'PrcntPrbC';

*******************************************************************;
******** Variables for G *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NumG=sex|color1|head|femur;  title 'NumG';
proc glm data=two plots=diagnostics; class sex color1; model DurG=sex|color1|head|femur;  title 'DurG';
proc glm data=two plots=diagnostics; class sex color1; model MeanG=sex|color1|head|femur;  title 'MeanG';
proc glm data=two plots=diagnostics; class sex color1; model sdG=sex|color1|head|femur;  title 'sdG';
proc glm data=two plots=diagnostics; class sex color1; model CtoFrstG=sex|color1|head|femur;  title 'CtoFrstG';
proc glm data=two plots=diagnostics; class sex color1; model DurNnprbBfrFrstG=sex|color1|head|femur;  title 'DurNnprbBfrFrstG';
proc glm data=two plots=diagnostics; class sex color1; model meanNGPrb=sex|color1|head|femur;  title 'meanNGPrb';
proc glm data=two plots=diagnostics; class sex color1; model TmFrmFrstPrbFrstG=sex|color1|head|femur;  title 'TmFrmFrstPrbFrstG';
proc glm data=two plots=diagnostics; class sex color1; model TmBegPrbFrstG=sex|color1|head|femur;  title 'TmBegPrbFrstG';
proc glm data=two plots=diagnostics; class sex color1; model NumPrbsAftrFrstG=sex|color1|head|femur;  title 'NumPrbsAftrFrstG';
proc glm data=two plots=diagnostics; class sex color1; model NmbrShrtPrbAftrFrstG=sex|color1|head|femur;  title 'NmbrShrtPrbAftrFrstG';
proc glm data=two plots=diagnostics; class sex color1; model NumLngG=sex|color1|head|femur;  title 'NumLngG';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstSusGFrstPrb=sex|color1|head|femur;  title 'TmFrstSusGFrstPrb';
proc glm data=two plots=diagnostics; class sex color1; model PrcntPrbG=sex|color1|head|femur;  title 'PrcntPrbG';

*******************************************************************;
******** Variables for D *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NumD=sex|color1|head|femur; title 'NumD';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurD=sex|color1|head|femur;  title 'TtlDurD';
proc glm data=two plots=diagnostics; class sex color1; model MeanD=sex|color1|head|femur; title 'MeanD';
proc glm data=two plots=diagnostics; class sex color1; model sdD=sex|color1|head|femur; title 'sdD';
proc glm data=two plots=diagnostics; class sex color1; model CtoFrstD=sex|color1|head|femur;   title 'CtoFrstD';
proc glm data=two plots=diagnostics; class sex color1; model DurNnprbBfrFrstD=sex|color1|head|femur;   title 'DurNnprbBfrFrstD';
proc glm data=two plots=diagnostics; class sex color1; model meanNDPrb=sex|color1|head|femur;   title 'meanNDPrb';
proc glm data=two plots=diagnostics; class sex color1; model TmFrmFrstPrbFrstD=sex|color1|head|femur;   title 'TmFrmFrstPrbFrstD';
proc glm data=two plots=diagnostics; class sex color1; model TmBegPrbFrstD=sex|color1|head|femur;   title 'TmBegPrbFrstD';
proc glm data=two plots=diagnostics; class sex color1; model NumPrbsAftrFrstD=sex|color1|head|femur;   title 'NumPrbsAftrFrstD';
proc glm data=two plots=diagnostics; class sex color1; model NmbrShrtPrbAftrFrstD=sex|color1|head|femur;   title 'NmbrShrtPrbAftrFrstD';
proc glm data=two plots=diagnostics; class sex color1; model NumLngD=sex|color1|head|femur;   title 'NumLngD';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstSusDFrstPrb=sex|color1|head|femur;   title 'TmFrstSusDFrstPrb';
proc glm data=two plots=diagnostics; class sex color1; model MaxD=sex|color1|head|femur;   title 'MaxD';
proc glm data=two plots=diagnostics; class sex color1; model PrcntPrbD=sex|color1|head|femur;   title 'PrcntPrbD';
*/;
*******************************************************************;
******** Variables for E or E1 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NumE1=sex|color1|head|femur;   title 'NumE1';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE1=sex|color1|head|femur;   title 'TtlDurE1';
***Here is one example MnDurE1;
proc glm data=two plots=diagnostics; class sex color1; model MnDurE1=sex|color1|head|femur;   title 'MnDurE1';
***And another;
proc glm data=two plots=diagnostics; class sex color1; model sdE1=sex|color1|head|femur;   title 'sdE1';
proc glm data=two plots=diagnostics; class sex color1; model CtoFrstE1=sex|color1|head|femur;   title 'CtoFrstE1';
proc glm data=two plots=diagnostics; class sex color1; model TmFrmFrstPrbFrstE=sex|color1|head|femur;   title 'TmFrmFrstPrbFrstE';
proc glm data=two plots=diagnostics; class sex color1; model TmBegPrbFrstE=sex|color1|head|femur;   title 'TmBegPrbFrstE';
proc glm data=two plots=diagnostics; class sex color1; model NumPrbsAftrFrstE=sex|color1|head|femur;   title 'NumPrbsAftrFrstE';
proc glm data=two plots=diagnostics; class sex color1; model NmbrShrtPrbAftrFrstE=sex|color1|head|femur;   title 'NmbrShrtPrbAftrFrstE';
proc glm data=two plots=diagnostics; class sex color1; model NumLngE1BfrE2=sex|color1|head|femur;   title 'NumLngE1BfrE2';
proc glm data=two plots=diagnostics; class sex color1; model NumSnglE1=sex|color1|head|femur;   title 'NumSnglE1';
proc glm data=two plots=diagnostics; class sex color1; model DurFirstE=sex|color1|head|femur; title 'DurFirstE';
proc glm data=two plots=diagnostics; class sex color1; model CntrbE1toE=sex|color1|head|femur;   title 'CntrbE1toE';
proc glm data=two plots=diagnostics; class sex color1; model DurE1FlwdFrstSusE2=sex|color1|head|femur;   title 'DurE1FlwdFrstSusE2';
proc glm data=two plots=diagnostics; class sex color1; model DurE1FlldFrstE2=sex|color1|head|femur;   title 'DurE1FlldFrstE2';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE1FlldSusE2=sex|color1|head|femur;   title 'TtlDurE1FlldSusE2';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE1FlldE2=sex|color1|head|femur;   title 'TtlDurE1FlldE2';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurSnglE1=sex|color1|head|femur;   title 'TtlDurSnglE1';
proc glm data=two plots=diagnostics; class sex color1; model PrcntPrbE1=sex|color1|head|femur;   title 'PrcntPrbE1';

*******************************************************************;
******** Variables for E2 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model NumE2=sex|color1|head|femur;   title 'NumE2';
proc glm data=two plots=diagnostics; class sex color1; model NumLngE2=sex|color1|head|femur;   title 'NumLngE2';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE2=sex|color1|head|femur;   title 'TtlDurE2';
proc glm data=two plots=diagnostics; class sex color1; model MnDurE2=sex|color1|head|femur;   title 'MnDurE2';
proc glm data=two plots=diagnostics; class sex color1; model sdE2=sex|color1|head|femur;   title 'sdE2';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstSusE2FrstPrb=sex|color1|head|femur;   title 'TmFrstSusE2FrstPrb';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstSusE2StrtPrb=sex|color1|head|femur;   title 'TmFrstSusE2StrtPrb';

proc glm data=two plots=diagnostics; class sex color1; model TmFrstE2StrtEPG=sex|color1|head|femur;   title 'TmFrstE2StrtEPG';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstE2FrmFrstPrb=sex|color1|head|femur;   title 'TmFrstE2FrmFrstPrb';
proc glm data=two plots=diagnostics; class sex color1; model TmFrstE2FrmPrbStrt=sex|color1|head|femur;   title 'TmFrstE2FrmPrbStrt';
proc glm data=two plots=diagnostics; class sex color1; model TmLstE2EndRcrd=sex|color1|head|femur;   title 'TmLstE2EndRcrd';
proc glm data=two plots=diagnostics; class sex color1; model maxE2=sex|color1|head|femur;   title 'maxE2';
proc glm data=two plots=diagnostics; class sex color1; model PrcntPrbE2=sex|color1|head|femur;   title 'PrcntPrbE2';
proc glm data=two plots=diagnostics; class sex color1; model PrcntE2SusE2=sex|color1|head|femur;   title 'PrcntE2SusE2';

*******************************************************************;
******** Variables for E1+E2 *************************;
*******************************************************************;
proc glm data=two plots=diagnostics; class sex color1; model PotE2Indx=sex|color1|head|femur;   title 'PotE2Indx';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE=sex|color1|head|femur;   title 'TtlDurE';
proc glm data=two plots=diagnostics; class sex color1; model TtlDurE1FllwdE2PlsE2=sex|color1|head|femur;   title 'TtlDurE1FllwdE2PlsE2';
proc glm data=two plots=diagnostics; class sex color1; model TotDurNnPhlPhs=sex|color1|head|femur;   title 'TotDurNnPhlPhs';*Duration of recording less E1 and E2;
proc glm data=two plots=diagnostics; class sex color1; model TmFrstSusE2=sex|color1|head|femur;   title 'TmFrstSusE2';
run;
